surface: Track all draw contexts created for the surface
authorBenjamin Otte <otte@redhat.com>
Sun, 8 Apr 2018 22:25:03 +0000 (00:25 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 8 Apr 2018 23:00:31 +0000 (01:00 +0200)
gdk/gdkdrawcontext.c
gdk/gdkinternals.h

index 565dd307d5579810f5d448b78d2d5dddfbe3be17..0f020f93e33c63edb0c8c1408b1571d6923fa090 100644 (file)
@@ -73,7 +73,11 @@ gdk_draw_context_dispose (GObject *gobject)
   GdkDrawContext *context = GDK_DRAW_CONTEXT (gobject);
   GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
 
-  g_clear_object (&priv->surface);
+  if (priv->surface)
+    {
+      priv->surface->draw_contexts = g_slist_remove (priv->surface->draw_contexts, context);
+      g_clear_object (&priv->surface);
+    }
 
   G_OBJECT_CLASS (gdk_draw_context_parent_class)->dispose (gobject);
 }
@@ -92,6 +96,7 @@ gdk_draw_context_set_property (GObject      *gobject,
     case PROP_SURFACE:
       priv->surface = g_value_dup_object (value);
       g_assert (priv->surface != NULL);
+      priv->surface->draw_contexts = g_slist_prepend (priv->surface->draw_contexts, context);
       break;
 
     default:
index e17b355200951a93c4a4caf43d0878f4773cca83..4a56b91c1d0413780e70706b3d67f9c28f324047 100644 (file)
@@ -223,6 +223,7 @@ struct _GdkSurface
 
   GdkFrameClock *frame_clock; /* NULL to use from parent or default */
 
+  GSList *draw_contexts;
   GdkDrawingContext *drawing_context;
 
   cairo_region_t *opaque_region;